<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>修改</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/src/css/public.css">
</head>

<body>
    <div style="padding: 10px;">
        <form class="layui-form" action="" lay-filter="layui-form-Table">
            <ul class="layui-form layui-form-pane formUl" style="margin: 15px;">
                <li class="layui-form-item">
                    <label class="layui-form-label">区域代码</label>
                    <div class="layui-input-block">
                        <input type="text" name="areanumber" lay-verify="required" autocomplete="off" placeholder="请输入字段1" class="layui-input">
                    </div>
                </li>
                <li class="layui-form-item">
                    <label class="layui-form-label">区域名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="areaname" lay-verify="required" autocomplete="off" placeholder="请输入区域名称" class="layui-input">
                    </div>
                </li>

                <li class="layui-form-item">
                    <label class="layui-form-label">区域查询</label>
                    <div class="layui-input-block">
                        <input type="text" name="abbreviation" lay-verify="required" autocomplete="off" placeholder="请输入区域查询" class="layui-input">
                    </div>
                </li>
                <li class="layui-form-item">
                    <label class="layui-form-label">区域简称</label>
                    <div class="layui-input-block">
                        <input type="text" name="shortareaname" lay-verify="required" autocomplete="off" placeholder="请输入区域简称" class=" layui-input ">
                    </div>
                </li>
                <li class="layui-form-item ">
                    <label class="layui-form-label ">排序</label>
                    <div class="layui-input-block ">
                        <input type="text " name="paixu" lay-verify="required " autocomplete="off " placeholder="请输入排序 " class="layui-input ">
                    </div>
                </li>
                <li class="layui-form-item ">
                    <label class="layui-form-label ">人口数量</label>
                    <div class="layui-input-block ">
                        <input type="text " name="rksl" autocomplete="off " placeholder="请输入人口数量 " class="layui-input ">
                    </div>
                </li>
            </ul>

            <div style="text-align: center;">
                <input type="hidden" name="id" value="0">
                <button class="layui-btn" lay-submit lay-filter="YjbtnSave" id="YjbtnSave" type="button">提交</button>
            </div>
        </form>
    </div>
    <script src="/layui/layui.js"></script>
    <script>
        layui.config({
            base: '/src/'
        }).use('index', function() {
            var admin = layui.admin,
                main = layui.main,
                form = layui.form,
                table = parent.layui.table;

            //加载表单内容
            admin.req({
                url: 'system/area/Edit',
                type: 'get',
                data: {
                    id: main.getPageParams('id')
                },
                done: function(res) {
                    if (res.successful) {
                        form.val("layui-form-Table", {
                            "id": res.data.id,
                            "areanumber": res.data.areanumber,
                            "areaname": res.data.areaname, 
                            "abbreviation": res.data.abbreviation,
                            "shortareaname": res.data.shortareaname,
                            "paixu": res.data.paixu, 
                            "rksl": res.data.rksl
                        });
                    }
                }
            });

            //保存
            form.render().on('submit(YjbtnSave)', function(data) {
                admin.req({
                    url: 'system/area/UpdateInfo',
                    data: JSON.stringify(data.field),
                    contentType: 'application/json',
                    type: 'put',
                    done: function(res) {
                        if (res.successful) {
                            main.msg_success(res.msg);
                            table.reload('LAY-app-area-list');
                        } else {
                            main.msg_error(res.msg);
                        }
                    }
                });
            });
        });
    </script>
</body>

</html>